#!/bin/bash

echo "========================================"
echo "   AI智能助手 - Vue3版本启动脚本"
echo "========================================"
echo

echo "检查Node.js环境..."
if ! command -v node &> /dev/null; then
    echo "❌ 未检测到Node.js，请先安装Node.js"
    echo "下载地址: https://nodejs.org/"
    exit 1
fi

echo "✅ Node.js环境正常"
echo

echo "检查依赖包..."
if [ ! -d "node_modules" ]; then
    echo "📦 首次运行，正在安装依赖包..."
    npm install
    if [ $? -ne 0 ]; then
        echo "❌ 依赖包安装失败"
        exit 1
    fi
    echo "✅ 依赖包安装完成"
else
    echo "✅ 依赖包已存在"
fi

echo
echo "🚀 启动开发服务器..."
echo "访问地址: http://localhost:5175"
echo "按 Ctrl+C 停止服务器"
echo

npm run dev
